<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文案生成</title>
    <style>
        body{
            background:linear-gradient(135deg,#b4b9c1,#4780c6);
            min-height: 100vh;
            margin: 0;
            padding: 0;
            font-family: sans-serif;
            padding: 20px;
            box-sizing: border-box;
        }
        .title{
            text-align: center;
            margin-top: 20px;
            margin-bottom: 30px;
            font-size: 35px;
            color: white;
        }
        /* 主容器采用弹性布局，实现三列并排 */
        .main-container{
            display: flex;
            justify-content: center;
            gap: 30px;
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            align-items: flex-start;
        }
        .introduce{
            text-align: center;
            border: 2px dashed #fff;
            padding: 20px;
            border-radius: 10px; 
            color: white;
            flex: 1;
            min-width: 250px;
        }
        .content{
            flex: 1.2;
            min-width: 280px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .example {
            text-align: center;
            border: 2px dashed #fff;
            padding: 20px;
            border-radius: 10px;
            font-size: 20px;
            color: white;
            flex: 1;
            min-width: 250px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        .input{
            width: 100%;
            height: 65px;
            border-radius: 15px;
            font-size: 25px;
            border: none;
            outline: none;
            padding: 0 15px;
            box-sizing: border-box;
        }
        button{
            width: 100px;
            height: 40px;
            border-radius: 15px;
            border: none;
            outline: none;
            background: #fff;
            margin-top: 20px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: background 0.3s;
        }
        button:hover{
            background: #e0e0e0;
        }
        .selling-points {
            margin-top: 20px;
            color: white;
            width: 100%;
        }
        .selling-points h3{
            margin-bottom: 15px;
            text-align: center;
        }
        .selling-points label{
            display: block;
            margin: 10px 0;
            cursor: pointer;
        }
        .result {
            margin-top: 30px;
            background: white;
            border-radius: 15px;
            padding: 20px;
            width: 100%;
            min-height: 100px;
            display: none;
            box-sizing: border-box;
        }
        /* 响应式调整，在小屏幕上改为垂直排列 */
        @media (max-width: 900px) {
            .main-container{
                flex-direction: column;
                align-items: center;
            }
            .introduce, .example, .content{
                width: 100%;
                max-width: 500px;
            }
        }
    </style>
</head>
<body>
    <!-- 头部标题部分 -->
    <div class="title">
        <h1>文案生成</h1>
    </div>
    
    <!-- 主容器：左侧介绍，中间输入，右侧宣传语 -->
    <div class="main-container">
        <!-- 左侧：产品介绍 -->
        <div class="introduce">
            <h2>产品介绍&使用说明</h2>
            <p>本产品用于生成商品文案</p>           
            <p><b>使用说明</b></p>
            <p>1.输入商品名称</p>
            <p>2.根据提示选择产品卖点</p>
            <p>3.点击生成</p>
            <p>4.在下方查看生成结果</p>
         </div>
         
         <!-- 中间：输入框和选择框 -->
        <div class="content">
            <input type="text" class="input" id="productName" placeholder="请输入商品名称">
            
            <div class="selling-points">
                <h3>选择产品卖点：</h3>
                <label>
                    <input type="checkbox" name="feature" value="质量上乘"> 质量上乘
                </label>
                <label>
                    <input type="checkbox" name="feature" value="价格优惠"> 价格优惠
                </label>
                <label>
                    <input type="checkbox" name="feature" value="设计精美"> 设计精美
                </label>
                <label>
                    <input type="checkbox" name="feature" value="性价比高"> 性价比高
                </label>
                <label>
                    <input type="checkbox" name="feature" value="独家限量"> 独家限量
                </label>
            </div>
            
            <button id="btn">生成</button>
            
            <div class="result" id="result"></div>
        </div>
        
        <!-- 右侧：宣传语 -->
        <div class="example">
            <p>言为心声，文以载道。<br><br>
               吾有神器，名曰文案生成。<br><br>
               取汝之意，成吾之文，<br><br>
               传君之名于四海。</p>
        </div>
    </div>
    

    <script>
        // 获取DOM元素
        const btn = document.getElementById('btn');
        const productNameInput = document.getElementById('productName');
        const resultDiv = document.getElementById('result');
        
        // 定义固定文案模板
        const templates = [
            "推荐这款{product}，{features}，是您不容错过的好选择！",
            "{product}全新上市，{features}，深受消费者喜爱，快来选购吧！",
            "想要{features}的产品？{product}就是您的理想之选，品质保证，值得信赖。",
            "精选{product}，{features}，让您用得放心，买得开心！",
            "别再犹豫了，{product}拥有{features}等诸多优点，是同类产品中的佼佼者。"
        ];
        
        // 绑定生成按钮点击事件
        btn.addEventListener('click', function() {
            // 获取商品名称
            const productName = productNameInput.value.trim();
            
            // 验证商品名称
            if (!productName) {
                alert('请输入商品名称');
                return;
            }
            
            // 获取选中的卖点
            const selectedFeatures = [];
            document.querySelectorAll('input[name="feature"]:checked').forEach(checkbox => {
                selectedFeatures.push(checkbox.value);
            });
            
            // 验证卖点选择
            if (selectedFeatures.length === 0) {
                alert('请至少选择一个产品卖点');
                return;
            }
            
            // 将卖点数组转换为字符串
            const featuresText = selectedFeatures.join('、');
            
            // 随机选择一个模板
            const randomTemplate = templates[Math.floor(Math.random() * templates.length)];
            
            // 替换模板中的占位符
            const generatedText = randomTemplate
                .replace('{product}', productName)
                .replace('{features}', featuresText);
            
            // 显示生成的文案
            resultDiv.textContent = generatedText;
            resultDiv.style.display = 'block';
            
            // 添加简单的显示动画
            resultDiv.style.opacity = '0';
            let opacity = 0;
            const interval = setInterval(() => {
                opacity += 0.1;
                resultDiv.style.opacity = opacity;
                if (opacity >= 1) {
                    clearInterval(interval);
                }
            }, 30);
        });
    </script>
</body>
</html>